<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');



if($_POST['act']=='edit'){
		$role=$_POST['role'];
		$depict=trim($_POST['depict']);
		$edid=$_POST['edid'];
		$pwd=trim($_POST['pwd']);
		$status=$_POST['status'];
		if(empty($edid)) show_automsg('数据丢失无法提交',YMCURL.'controllist',1);
		if(empty($role)) show_automsg('请选择一个角色',YMCURL.'controllist',1);
		if($edid==1) show_automsg('该账号禁止编辑',YMCURL.'controllist',1);
		if($role==1){
			show_automsg('不能分派此角色!',$GLOBALARR['curl'],1);
		}

		if(!empty($pwd)){
			$p=chkpwd(array($pwd));
			if($p!='true'){
				show_automsg($p,$GLOBALARR['curl'],1);
			}
			$p=getpwd($pwd);
			$psql=",password='$p'";	
		}

		$db->query('select * from ld_user where uid='.$edid,2);
		if(empty($db->rs)){
			show_automsg('找不到此管理！',YMCURL.'controllist',1);
		}else{
			$uname=$db->rs["uname"];
		}
		$sql="update ld_user set role=$role,admin_status=$status,depict='$depict' $psql where uid=$edid";
                //echo $sql;exit;
		$db->sitedbexec($sql);
		record_log('修改管理'.$uname);
		show_automsg('修改管理成功！',YMCURL.'controllist');
}

$edid=getnums($_GET['edid'],0);

$db->query('select * from ld_user where uid='.$edid,2);
if(empty($db->rs)){
	show_automsg('找不到此管理！',YMCURL.'controllist',1);
}
$role=$db->rs['role'];
echo '<h3>管理编辑</h3>';
echo '<div class="main-r-body"><form method="post" action="'.geturl().'">
		<div class="main-r-item"><a href="'.YMCURL.'controllist" class="thabtn">返回管理列表</a><input type="submit" class="thabtn" value="提交"></div>
		<input type="hidden" name="act" value="edit"><input type="hidden" name="edid" value="'.$db->rs['uid'].'">';
echo '<table class="tregtab ttab">';
echo '	<tr>
			<td class="wdb20 alignr paddingr">会员账号</td>
			<td class="alignl paddingl">'.$db->rs['uname'].'</td>
		</tr>';
echo '	<tr>
			<td class="wdb20 alignr paddingr">密码</td>
			<td class="alignl paddingl"><input type="password" name="pwd" value="" class="thconfig wd400"> 注:不修改请为空</td>
		</tr>';		
echo '	<tr>
			<td class="wdb20 alignr paddingr">状态</td>
			<td class="alignl paddingl">'.tradio(array('status',$db->rs['status']),2).'</td>
		</tr>';			
echo '	<tr>
			<td class="wdb20 alignr paddingr">描述</td>
			<td class="alignl paddingl"><input type="text" name="depict" value="'.$db->rs['depict'].'" class="thconfig wd400"></td>
		</tr>';		
echo '	<tr>
			<td class="wdb20 alignr paddingr" valign="top" >指派角色</td>
			<td class="alignl paddingl">';
echo '<select name="role" class="thconfig" style="color:#fff;text-indent:0;background:#272822;line-height:30px;height:30px">';
$db->query('select * from ld_privilege where `status`=0');
foreach ($db->rs as $k => $v) {
if($edid>1){
	if($v['edid']==1) continue;
}
echo '<option value="'.$v['edid'].'" '.geteqval(array($role,$v['edid'],'selected','')).'>'.$v['rolename'].'</option>';
}
echo '</select>';
echo '		</td>
		</tr>';		
echo '</table>';
echo '</form></div>';		

?>